
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>消费者模式及适用场景 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>消费者模式及适用场景 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">RocketMQ的Push模式虽然名为“推模式”，但其底层的真实实现机制是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Push模式的实际实现是基于长轮询(Long Polling)机制，它在Consumer端主动拉取消息的基础上模拟了服务端推送的效果。</div>
          </div>
          <div class="card-source">来源: Push模式基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Push模式的长轮询过程中，如果Broker暂时没有新消息，会如何处理消费者的拉取请求？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">如果Broker没有可消费的消息，它会挂起请求一段时间（默认15秒）。在这期间，若有新消息到达，会立即返回给Consumer；如果超时仍无消息，则返回空结果，Consumer会立刻发起下一次拉取请求。</div>
          </div>
          <div class="card-source">来源: Push模式的工作流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">请列举RocketMQ Push模式的三个核心特点。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Push模式的核心特点包括：1. 自动化程度高（消息拉取、提交、重试对用户透明）；2. 实时性较好（长轮询能确保新消息及时处理）；3. 系统负载自动平衡（能根据消费能力自动调整拉取频率）。</div>
          </div>
          <div class="card-source">来源: Push模式的核心特点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">RocketMQ的Pull模式在消费控制权上与Push模式有何根本区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Pull模式是完全由应用主动控制的消费方式，Consumer应用需要显式调用API来拉取消息，从而自主掌控消息的消费节奏和处理逻辑。而Push模式的消息拉取、提交等过程对用户是透明的。</div>
          </div>
          <div class="card-source">来源: Pull模式基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Pull模式在消费位点管理方面提供了哪些灵活性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Pull模式允许应用负责记录和更新消费位点，可以根据业务需要决定位点提交的时机，支持自定义位点存储，并能实现非常规的消费模式，例如回溯消费。</div>
          </div>
          <div class="card-source">来源: Pull模式的核心优势</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Pull模式下，当应用代码调用pullMessage方法时，通常需要指定哪些关键参数？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Pull模式下，应用代码调用pullMessage方法时需要指定Topic、队列、位点和批次大小，并可以设置拉取超时时间。</div>
          </div>
          <div class="card-source">来源: Pull模式的执行流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">对于实时性要求高且处理逻辑相对简单的业务（如实时通知系统），应优先选择哪种消费模式？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应优先选择Push模式。该模式适用于实时性要求高的场景（如实时通知、即时计算、告警系统）和消息处理逻辑简单的场景。</div>
          </div>
          <div class="card-source">来源: Push模式适用场景</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">当业务需要批量处理消息（如ETL）或需要实现消息回溯等特殊消费逻辑时，哪种消费模式更合适？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Pull模式更合适。它适用于批量处理优先的场景（如数据分析、批量计算、ETL处理）以及需要实现特殊消费模式的场景（如消息回溯、定制重试逻辑）。</div>
          </div>
          <div class="card-source">来源: Pull模式适用场景</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在选择消费模式时，业务特性和系统资源是如何影响决策的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">根据业务特性，实时性高且逻辑简单的场景适合Push模式，而需要精细控制和批量处理的场景适合Pull模式。根据系统资源，消费端资源充足时Push模式更便捷，而资源受限或需要精确控制时Pull模式更高效。</div>
          </div>
          <div class="card-source">来源: 选择指南与最佳实践</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
